﻿using MeetAI.Model;
using MeetAI.Repository.IRepository;
using MeetAI.Service.IService;
using System.Threading.Tasks;

namespace MeetAI.Service
{
    public class Dy_Message_Service : BaseService<dy_message>, IDy_Message_Service
    {
        private readonly IDy_Message_Repository _repository;
        private readonly IDy_Message_Field_Repository _field_Repository;
        public Dy_Message_Service(IDy_Message_Repository repository, IDy_Message_Field_Repository field_Repository) : base(repository)
        {
            _repository = repository;
            _field_Repository = field_Repository;
        }

        public async Task<long> userComment(dy_message message)
        {
            long commentId = await _repository.InsertAsync(message);
            if(commentId > 0)
            {
                dy_message_field message_Field = new dy_message_field
                {
                    aid = int.Parse(commentId + ""),
                    lianxi= message.mobile,
                    xingming=message.user,
                    hq=0
                };
                await _field_Repository.InsertAsync(message_Field);
            }
            return commentId;
        }
    }
}
